import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;




public class make_bugid_svnid 
{
   public Connection conn=  null;
   
   

private void process(Connection conn) 
{   	
      Statement stmt =  null;
      String str = "select * from bug_svn_info";
      
		try
		{
			stmt =  conn.createStatement();
		
	    stmt.execute(str);
	    ResultSet rs  = stmt.getResultSet();
	    while(rs.next())
	    {
	    	try
	        {
	    	String bugid = rs.getString("bugid");
	    	String svnids =rs.getString("svn_id");
	    	
	    	String svn[] = svnids.split(",");
	    	
	    	insert(bugid,svn,conn);
	    } catch (SQLException e) 
	      { e.printStackTrace(); }
	    }
	    
	    if(rs!=null)
	    	rs.close();
	    if(stmt!=null)
	    	stmt.close();
		}catch(SQLException e)
		{
			e.printStackTrace();
		}
     
}
   
private void insert(String bugid, String[] svn, Connection conn) 
{
	for(int i=0;i<svn.length;i++)
	 {

		try 
		{Statement  stmt =  conn.createStatement();
		String str = "insert into bug_svn_only values('"+bugid+"','"+svn[i]+"')";
	    stmt.executeUpdate(str);
		} catch (SQLException e) 
		{ System.out.println("ex="+bugid); }
	 }
	
	
	
}

public static void main(String args[])
   {
	 make_bugid_svnid mbs =  new make_bugid_svnid();
	 db_conn db =  new db_conn();
	 mbs.conn = db.connect("2jboss","root","123");
	 mbs.process(db.conn);
	 
	 db.close(db.conn);
   }


}
